package com.hsylient.javase.chapter11.demo08;

/**
 * 创建一个子线程
 * <p>
 * 让子线程睡眠5秒钟
 * 1.刚开始没有调用start方法是一个新建的状态
 * 2.
 */
public class ThreadStatus {

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("子线程。。。。");
        });

        System.out.println(thread.getState());
        thread.start();
        System.out.println(thread.getState());

        while (thread.getState() != Thread.State.TERMINATED) {
            Thread.sleep(100);
            System.out.println(thread.getState());
        }
    }
}
